package com.netease.streamlearningbyjava;

import com.netease.streamlearningbyjava.bean.Employee2;

import org.junit.Test;

import java.util.Arrays;
import java.util.DoubleSummaryStatistics;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 创建日期：2021/11/8 10:58
 *
 * @author tony.sun
 * 类说明：规约与收集
 */

public class Stream13Test {
    List<Employee2> employee2s = Arrays.asList(
            new Employee2("张三", 18, 9999.99, Employee2.Status.FREE),
            new Employee2("李四", 58, 5555.55, Employee2.Status.BUSY),
            new Employee2("王五", 26, 3333.33, Employee2.Status.VOCATION),
            new Employee2("赵六", 36, 6666.66, Employee2.Status.FREE),
            new Employee2("赵六", 36, 6666.66, Employee2.Status.FREE),
            new Employee2("田七", 12, 8888.88, Employee2.Status.BUSY)
    );

    @Test
    public void test() {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
        Stream<Integer> integerStream = list.stream()
                .map((e) -> e * e);
        integerStream.forEach(System.out::println);
    }

    @Test
    public void test2() {
        Optional<Integer> reduce = employee2s.stream()
                .map((e)->1)
                .reduce(Integer::sum);
        System.out.println(reduce.get());
    }

    @Test
    public void test3() {

    }

    @Test
    public void test4() {

    }

    @Test
    public void test5() {

    }


}
